package com.example.pufang.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.pufang.mapper.CollectMapper;
import com.example.pufang.pojo.Collect;
import com.example.pufang.pojo.House;
import com.example.pufang.pojo.User;
import com.example.pufang.service.CollectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class CollectServiceImpl extends ServiceImpl<CollectMapper, Collect> implements CollectService {

    @Autowired
    private CollectMapper collectMapper;

    @Override
    public Boolean deleteByHouseUser(Collect collect) {

        LambdaQueryWrapper<Collect> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(Collect::getHouseId, collect.getHouseId())
                .eq(Collect::getUserId, collect.getUserId());

        collect = collectMapper.selectOne(wrapper);

        return collectMapper.deleteById(collect) > 0 ? true : false;
    }
}
